<script setup lang="ts">
import { Edit } from '@element-plus/icons-vue';
import { useRoute, useRouter } from 'vue-router';

const $route = useRoute()
const $router = useRouter()
const props = defineProps(['user', 'index', 'currentIndex'])
const $emit = defineEmits(['changeScene'])
const handler = () => {
  if ($route.path === '/user/patient') {
    $emit('changeScene', props.user)
  } else {
    $router.push({ path: '/user/patient', query: { type: 'edit', id: props.user.id } })
  }
}
</script>



<template>
  <div class="visitor">
    <div class="top">
      <div class="left">
        <span class="type">{{ user.isInsure == 1 ? '医保' : '自费' }}</span>
        <span class="username">{{ user.name }}</span>
      </div>
      <div class="right">
        <el-button circle type="primary" size="default" :icon="Edit" @click="handler"></el-button>
        <!-- <el-button circle type="danger" size="default" :icon="Delete"></el-button> -->
        <slot name="buttons"></slot>
      </div>
    </div>
    <div class="bottom">
      <p>证件类型:{{ user.param.certificatesTypeString }}</p>
      <p>证件号码:{{ user.certificatesNo }}</p>
      <p>用户性别:{{ user.sex == 0 ? "女生" : "男士" }}</p>
      <p>出生日期:{{ user.birthdate }}</p>
      <p>手机号码:{{ user.phone }}</p>
      <p>婚姻状况:{{ user.isMarry == 0 ? "未婚" : "已婚" }}</p>
      <p>当前住址:{{ user.param.cityString }}</p>
      <p>详细地址:{{ user.param.fullAddress }}</p>
      <!-- 已选择的就诊人 -->
      <transition name="confirm">
        <div class="confirm" v-if="index === currentIndex">已选择</div>
      </transition>
    </div>
  </div>
</template>



<style scoped lang="scss">
.visitor {
  box-shadow: 0px 0px 12px rgba(0, 0, 0, 0.12);

  .top {
    width: 100%;
    height: 60px;
    background: #e5e5e5;
    display: flex;
    justify-content: space-between;
    align-items: center;

    .left {
      margin-left: 10px;

      .type {
        background-color: #fff;
        padding: 5px;
        font-size: 12px;
        margin-right: 5px;
        border-radius: 10px;
      }

      .username {
        color: #7f7f7f;
      }

    }

    .right {
      margin-right: 10px;
    }
  }

  .bottom {
    padding: 30px;
    position: relative;

    p {
      line-height: 30px;
    }

    .confirm {
      position: absolute;
      left: 20%;
      top: 20%;
      opacity: 0.5;
      transform: rotate(25deg);
      width: 200px;
      height: 200px;
      color: red;
      border-radius: 50%;
      border: 1px dashed red;
      font-weight: 700;
      text-align: center;
      line-height: 200px;
    }

    .confirm-enter-form {
      transform: scale(1);
    }

    .confirm-enter-active {
      transition: all .4s;
    }

    .confirm-enter-to {
      transform: scale(1.3);
    }
  }
}
</style>